package com.example.esp8266;

import android.text.TextUtils;

import org.w3c.dom.Text;

import java.util.Objects;

public class MqttParamsWrapper {
    private String productKey;
    private String deviceName;
    private String deviceSecret;
    private String pub_topic;
    private String sub_topic;

    public MqttParamsWrapper(String productKey, String deviceName, String deviceSecret) {
        this.productKey = productKey;
        this.deviceName = deviceName;
        this.deviceSecret = deviceSecret;
        this.pub_topic = "/sys/" + productKey + "/" + deviceName + "/thing/event/property/post";
        this.sub_topic = "/sys/" + productKey + "/" + deviceName + "/thing/service/property/set";
    }

    public MqttParamsWrapper(String productKey, String deviceName, String deviceSecret, String pub_topic, String sub_topic) {
        this.productKey = productKey;
        this.deviceName = deviceName;
        this.deviceSecret = deviceSecret;
        this.pub_topic = pub_topic;
        this.sub_topic = sub_topic;
    }

    public boolean isEmpty(){
        return TextUtils.isEmpty(productKey) || TextUtils.isEmpty(deviceName) || TextUtils.isEmpty(deviceSecret);
    }
    public String getProductKey() {
        return productKey;
    }

    public void setProductKey(String productKey) {
        this.productKey = productKey;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getDeviceSecret() {
        return deviceSecret;
    }

    public void setDeviceSecret(String deviceSecret) {
        this.deviceSecret = deviceSecret;
    }

    public String getPub_topic() {
        return pub_topic;
    }

    public void setPub_topic(String pub_topic) {
        this.pub_topic = pub_topic;
    }

    public String getSub_topic() {
        return sub_topic;
    }

    public void setSub_topic(String sub_topic) {
        this.sub_topic = sub_topic;
    }

    public AliyunClipboardBean toAliyunClipBean(){
        return new AliyunClipboardBean(productKey,deviceName,deviceSecret);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MqttParamsWrapper that = (MqttParamsWrapper) o;
        return TextUtils.equals(productKey, that.productKey) && TextUtils.equals(deviceName, that.deviceName) && TextUtils.equals(deviceSecret, that.deviceSecret);
    }

    @Override
    public int hashCode() {
        return Objects.hash(productKey, deviceName, deviceSecret);
    }
}
